My fizzbuzz in C

11 04 2013

This is my version of the fizzbuzz test, written in C:

char *arr[] = {"%d\n", "fizz\n", "buzz\n", "fizzbuzz\n"}; 
for (int i=1; i<=100; i++) printf(arr[!(i%3)+2*!(i%5)], i);

or rephrased in a more readable format:

char *arr[] = {"%d\n", "fizz\n", "buzz\n", "fizzbuzz\n"}; 

int i, index;

for (i=1; i<=100; i++)
{
	index = !(i%3) + 2 * !(i%5);
	printf( arr[index], i);
}

Actions

Information

2 responses

27 07 2013
Free Classified's avatar Free Classified

Thanks for this post, it helpfull for me

31 03 2014
Gladys's avatar Gladys

I think the admin of this web page is genuinely working hard in support of his site, as here every stuff is quality based material.

Leave a comment




Design a site like this with WordPress.com
Get started